package com.dks.repository.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.dks.mapper.StudentTaskMapper;
import com.dks.models.StudentTask;
import com.dks.repository.IStudentTaskRepository;
import com.dks.result.*;
import com.dks.util.PageInfo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Repository
public class StudentTaskRepository implements IStudentTaskRepository {

    @Autowired
    private StudentTaskMapper studentTaskMapper;

    /**
     * 作业查询
     * 查询条件：班级id(qsClassId)、学生id(studentId)
     */
    @Override
    public ResultModel<PageInfo<StudentTask>> list(Integer qsClassId, Integer studentId, Integer pageNum, Integer pageSize) {
        Page p= PageHelper.startPage(pageNum, pageSize);
        List<StudentTask> studentTaskList = studentTaskMapper.list(qsClassId, studentId);
        PageInfo<StudentTask> pageInfo = new PageInfo<>(pageNum,pageSize,p.getTotal(),p.getPages(),studentTaskList);
        return Result.makeResult(ResultInfo.SUCCESS, pageInfo);
    }
}
